package com.fjsh.enums;

public enum HttpStatus {

    /**
     * 操作成功
     */
    SUCCESS(200, "操作成功"),

    /**
     * 系统繁忙
     */
    EXCEPTION(500,"系统繁忙");

    private final int code;
    private final String message;

    HttpStatus(final int code, final String message) {
        this.code = code;
        this.message = message;
    }

    public static HttpStatus getStatus(int code) {
        HttpStatus[] httpStatuses = HttpStatus.values();
        for (HttpStatus httpStatus : httpStatuses) {
            if (httpStatus.getCode() == code) {
                return httpStatus;
            }
        }
        return SUCCESS;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}
